const routes = [
  {
    path: '/',
    redirect: '/home',
    component: () => import('@/pages/Home'),
    meta: { show: true }
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/pages/Home'),
    meta: { show: true }
  },
  {
    path: '/search/:keyword?',
    component: () => import('@/pages/Search'),
    meta: { show: true },
    name: 'search',
    props: true
  },
  {
    path: '/detail/:skuId?',
    component: () => import('@/pages/Detail'),
    meta: { show: true },
    name: 'detail'
  },
  // 添加到购物车成功跳转的路由 AddCartSuccess
  {
    path: '/addcartsuccess',
    component: () => import('@/pages/AddCartSuccess'),
    //路由元信息,控制当前路由是否需要Footer组件
    meta: { show: true },
    name: 'addcartsuccess'
  },
  // 购物车页面
  {
    path: '/shopcart',
    component: () => import('@/pages/ShopCart'),
    meta: { show: true },
    name: 'shopcart'
  },
  {
    path: '/login',
    component: () => import('@/pages/Login'),
    name: 'login',
    meta: { show: false }
  },
  {
    // 注册页面
    path: '/register',
    component: () => import('@/pages/Register'),
    meta: { show: false }
  },
  {
    // 交易页面--点击结算shopcart后跳转的页面
    path: '/trade',
    component: () => import('@/pages/Trade'),
    meta: { show: false },
    // 路由独享守卫
    // 要来trade页面之前的守卫
    beforeEnter:(to,from,next)=>{
      // 如果从shopcart页面来
      if(from.path == 'shopcart'){
        next()
      }else{
        // 从哪来回哪去
        next(false)
      }
    }
  },
  {
    // 支付页面
    path: '/pay',
    component: () => import('@/pages/Pay'),
    name: 'pay',
    meta: { show: false }
  },
  {
    // 立即支付--支付成功页面
    path: '/paysuccess',
    component: () => import('@/pages/PaySuccess'),
    name: 'paysuccess',
    meta: { show: false }
  },
  {
    // 查看订单页面
    path: '/center',
    component: () => import('@/pages/Center'),
    name: 'center',
    meta: { show: true },
    // 二级路由配置的地方
    children: [
      //我的订单
      {
        path: 'myorder',
        component: () => import('@/pages/Center/MyOrder'),
      },
      {
        path: 'Grouporder',
        component: () => import('@/pages/Center/GroupOrder'),
      },
      {
        path: '/center',
        redirect: '/center/myorder',
        component: () => import('@/pages/Center'),
      }
    ]
  }
]
export default routes
